home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C13 / PStash.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  718 b   |  30 lines

  1. //: C13:PStash.h
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Holds pointers instead of objects
  7. #ifndef PSTASH_H
  8. #define PSTASH_H
  9.  
  10. class PStash {
  11.   int quantity; // Number of storage spaces
  12.   int next; // Next empty space
  13.    // Pointer storage:
  14.   void** storage;
  15.   void inflate(int increase);
  16. public:
  17.   PStash() {
  18.     quantity = 0;
  19.     storage = 0;
  20.     next = 0;
  21.   }
  22.   // No ownership:
  23.   ~PStash() { delete []storage; }
  24.   int add(void* element);
  25.   void* operator[](int index) const; // Fetch
  26.   // Number of elements in Stash:
  27.   int count() const { return next; }
  28. };
  29. #endif // PSTASH_H ///:~
  30.